<template>
    <div class="Box">
        <div class="title">
            <span style="font-size: 0.5rem;" @click="drawer = true">
                <el-icon>
                    <User />
                </el-icon>
            </span>
            <span style="font-size: 0.5rem;">
                <el-icon>
                    <Menu />
                </el-icon>
            </span>
        </div>
        <el-drawer v-model="drawer" direction="ltr" size="60%" :show-close="false">
            <template #header>
                <span style="font-size: 0.5rem;" @click="drawer = false">
                    <el-icon>
                        <Fold />
                    </el-icon>
                </span>
            </template>
            <div style="margin-top: -0.5rem;">
                <img style="width: 1.5rem;" src="../assets/images/userlogo.png" alt="">
                <div
                    style="display: inline-block;vertical-align: top;font-size: 0.5rem;margin-left: 0.3rem;margin-top: 0.3rem;">
                    登录
                </div>
            </div>
            <div style="font-size: 0.4rem;margin-top: 1.5rem;">
                <div style="margin-bottom: 0.6rem;"><span style="margin-right:0.3rem;">🤍</span>我的关注</div>
                <div style="margin-bottom: 0.6rem;"><span style="margin-right: 0.3rem;">🔅</span>我的收藏</div>
                <div style="margin-bottom: 0.6rem;"><span style="margin-right: 0.3rem;">🥼</span>皮肤中心</div>
                <div><span
                        style="margin-right: 0.3rem;display: inline-block;width: 0.5rem;text-align: center;">✉</span>用户反馈
                </div>
            </div>

            <template #footer>
                <div style="text-align: left;font-size: 0.4rem;">
                    <div style="font-size: 0.5rem;margin-left: 0.1rem;"><el-icon>
                            <Setting />
                        </el-icon></div>
                    <div>设置</div>
                </div>
            </template>
        </el-drawer>
        <div class="main">
            <img class="logo" src="../assets/images/baidu.jpg" alt="">
            <div class="searchBox">
                <input type="text" class="search" placeholder="输入搜索词">
                <span class="camera">📷</span>
                <button>百度一下</button>
            </div>
            <div style="height: 0.2rem;background-color: rgb(241,241,241);"></div>
        </div>
        <div class="recommendText">
            <div class="Text1" @mouseover="lock = true" @mouseleave="lock = false" v-for="item in reInfo">
                <img :src="item.src" alt="">
                <div class="textInfo">
                    <h2>{{ item.title }}</h2>
                    <div class="leftInfoDetail">
                        <span>{{ item.time }}<span style="margin-left: 0.65rem;" v-show="lock">X</span></span>
                    </div>
                </div>
            </div>
            <div class="Text2" v-for="item in reInfo1">
                <h2>{{ item.title }}</h2>
                <div class="box">
                    <img :src="item.src" alt="">
                    <img :src="item.src" alt="">
                    <img :src="item.src" alt="">
                </div>
                <div class="time">
                    <span>{{ item.time }}</span>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import Nav from '../components/Nav.vue'
import Footer from '../components/Footer.vue';
import { useRouter } from 'vue-router';
import { User, Menu, Fold, Setting } from '@element-plus/icons-vue'

const router = useRouter();
const drawer = ref(false)
const lock = ref(false)

const reInfo = reactive([
    { src: 'http://localhost:5173/src/assets/images/info1.jpg', title: '没收油轮上的美国石油', time: '环球时报 03-07 09:27' },
    { src: 'http://localhost:5173/src/assets/images/info2.jpg', title: '欧洲央行继续“按兵不动”', time: '财联社 03-07 23:03' },
    { src: 'http://localhost:5173/src/assets/images/info3.jpg', title: '德国智库无法匹敌中国', time: '上观新闻 03-08 19:03' },
    { src: 'http://localhost:5173/src/assets/images/info4.jpg', title: '扎克伯格“抄作业”成功', time: '财联社 03-09 20:25' },
    { src: 'http://localhost:5173/src/assets/images/info5.jpg', title: 'TikTok干了一件大事', time: '全融界 03-10 20:03' },
])
const reInfo1 = reactive([
    { src: 'http://localhost:5173/src/assets/images/info1.jpg', title: '美联储“褐皮书”显示美国通胀压力仍普遍存在', time: '上观新闻 03-07 22:23' },
    { src: 'http://localhost:5173/src/assets/images/info2.jpg', title: '高爆传奇终于来了！10怪1万元宝,开局1人10狗！', time: '广告 03-07 23:03' },
    { src: 'http://localhost:5173/src/assets/images/info5.jpg', title: 'TikTok打爆每个会办公电话！', time: '证券时报 03-22 20:03' },
    { src: '', title: '山海退出跨航司退票互认机制，减少消费者出行损失', time: '文汇报 03-07 13:52' },
    { src: '', title: '江南化工：公司持有AI企业北京光年无限12.91%股份', time: '财联社 03-07 22:06' },
    { src: '', title: '中注协会同监管机构约谈新备案会计师事务所', time: '澎湃新闻 03-07 17:54' },
])

// 判断是否为PC端
const isPCFun = () => {
    const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    if (!isMobile) {
        router.push('/index')
    }
}

isPCFun()

</script>

<style lang="scss" scoped>
.Box {
    padding: 0.16rem;
    font-size: 0.104rem;

    .title {
        display: flex;
        justify-content: space-between;
        padding: 0.1rem;
    }

    .main {
        text-align: center;

        .logo {
            width: 4rem;
        }

        .searchBox {
            padding: 0.3rem 0 0.5rem;
            width: 90%;
            margin: 0rem auto;
            position: relative;

            .search {
                padding: 0.065rem 0rem 0.065rem 0.3rem;
                width: 100%;
                height: 1.2rem;
                border-radius: 0.2rem;
                outline-color: blue;
                border: 0.013rem solid gray;
            }

            .camera {
                position: absolute;
                top: 0.6rem;
                font-size: 0.4rem;
                right: 2.2rem;
                cursor: pointer;
            }

            button {
                border: none;
                height: 1.2rem;
                padding: 0 0.2rem;
                font-size: 0.4rem;
                color: white;
                background-color: rgb(78, 110, 242);
                position: absolute;
                right: 0rem;
                border-top-right-radius: 0.2rem;
                border-bottom-right-radius: 0.2rem;
            }

            button:hover {
                cursor: pointer;
                background-color: var(--hover-otherBlue);
            }
        }
    }

    .recommendText {
        padding: 0.3rem 0.1rem;
        width: 100%;

        .Text1 {
            width: 100%;
            cursor: pointer;
            padding-bottom: 0.5rem;

            img {
                width: 3.5rem;
                border-radius: 0.2rem;
            }

            .textInfo {
                display: inline-block;
                vertical-align: top;
                padding: 0.1rem;
                width: 5rem;
                margin-left: 0.1rem;

                h2 {
                    font-size: 0.4rem;
                    font-weight: 500;
                }

                .leftInfoDetail {
                    margin-top: 1.2rem;
                    font-size: 0.3rem;
                    display: flex;
                    color: gray;
                    justify-content: space-between;

                    span:hover {
                        color: var(--hover-blue)
                    }
                }
            }
        }

        .Text2 {
            cursor: pointer;

            h2 {
                font-size: 0.4rem;
                font-weight: 500;
                padding-bottom: 0.2rem;
            }

            .box {
                border-radius: 0.1rem;
                display: flex;
                overflow: hidden;
                justify-content: space-between;

                img {
                    width: 3rem;
                }
            }

            .time {
                padding: 0 0 0.3rem;
                font-size: 0.3rem;
                display: flex;
                color: gray;
                justify-content: space-between;
            }
        }

        .Text1:hover,
        .Text2:hover {
            h2 {
                color: var(--hover-blue);
            }
        }

    }
}
</style>